﻿using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;

namespace Xmart.Expressions.DynamicPredicate;

public interface IDynamicPredicateExtensions
{
    /// <summary>
    /// 自定义条件项转表达式
    /// </summary>
    /// <param name="item">条件项</param>
    /// <param name="propertyReflectedType">属性所属实例类型</param>
    /// <param name="propertyType">属性类型</param>
    /// <param name="memberExpression">属性访问表达式</param>
    /// <param name="cancellationToken">撤销令牌</param>
    /// <returns></returns>
    Task<Expression?> GetCustomPredicateAsync(DynamicPredicateItem item, Type propertyReflectedType, Type propertyType, Expression memberExpression, CancellationToken cancellationToken = default);

    /// <summary>
    /// 自定义值类型转换
    /// </summary>
    /// <param name="type">目的类型</param>
    /// <param name="value">字符串格式值</param>
    /// <param name="cancellationToken">撤销令牌</param>
    /// <returns></returns>
    Task<object?> ParseToValueTypeAsync(Type type, string value, CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取属于的列表
    /// </summary>
    /// <param name="type">类型</param>
    /// <param name="property">属性</param>
    /// <param name="value">获取属于的列表的值</param>
    /// <param name="cancellationToken">撤销令牌</param>
    /// <returns></returns>
    Task<IList> GetBelongToListAsync(Type type, string property, string value, CancellationToken cancellationToken = default);
}
